﻿@model IPagedList<MVCApp.Models.District>

@{
    ViewBag.Title = @Strings.MenuManageDistricts;
}

<h2>@ViewBag.Title</h2>

<div>
@using (Html.BeginForm("Index", "DistrictManage", FormMethod.Get))
{
    <input type="search" name="searchTerm" value="@ViewBag.SearchTerm" id="districtSearch"/>
    <input type="submit" value="@Strings.Search" /> 
}
    <div class="smallNote">
        u: użytkownik,  n: numer terenu
    </div>
</div>

<p>
    @Html.ActionLink("Create New", "Create")
</p>

@Html.Partial("_List", Model)

@section scripts {
    <script>
        $(function () {

            var submitAutocompleteForm = function (event, ui) {
                var $input = $(this);
                $input.val(ui.item.label);

                var $form = $input.parents("form:first");
                $form.submit();
            }

            $("#districtSearch").autocomplete({
                source: "@Url.Action("Autocomplete")",
                autoFocus: true,
                minLength: 1,
                select: submitAutocompleteForm
            });
        });
    </script>
}